{% form_theme form ':Form:fields.html.twig' %}
<a class="btn-reg-facebook sp" href="javascript:void(0);" onclick="registrarFacebook({{ ''|getFbAppId() }});">Usar Facebook</a>
<form action="{{ path('fos_user_registration_register') }}" enctype="multipart/form-data" method="POST" id="modal-form-registro" class="fos_user_registration_register" novalidate>
    <div class="left">
        {{ form_row(form.email) }}
        {{ form_row(form.nombre) }}
            
        <div class="formRow form_row_first first">
            <label for="fos_user_registration_form_plainPassword_first" class=" required">Clave:</label>
            {{ form_widget(form.plainPassword.first) }}
            <div class="error">
                {{ form_errors(form.plainPassword.first) }}
            </div>
        </div>
        <div class="formRow form_row_second second">
            <label for="fos_user_registration_form_plainPassword_second" class=" required">Repetir clave:</label>
            {{ form_widget(form.plainPassword.second) }}
            <div class="error">
                {{ form_errors(form.plainPassword.second) }}
            </div>
        </div>    
            
        <div class="radios">
            {{ form_row(form.sexo) }}
        </div>
        <div class="radios">
            {{ form_row(form.busco) }}
        </div>
        {{ form_row(form.para) }}
            
        <div class="formRow fotos">
            <label for="m-foto">Foto:</label>
            <input type="file" name="foto" id="m-foto">
        </div>
    </div>
    <div class="right">
        {{ form_row(form.cumple) }}
        {{ form_row(form.descripcion) }}
        {{ form_row(form.pais) }}
    </div>
    {{ form_rest(form) }}
        
    <div class="terminos">
        Acepto los <a href="{{ path('terminos') }}">Términos y Condiciones</a> y declaro ser mayor de 18 años
        <input type="checkbox" name="terminos" id="chk-terminos">
        <div class="error">
        </div>
    </div>
    <div class="actions">
        <input class="aceptar" type="submit" value="{{ 'registration.submit'|trans({}, 'FOSUserBundle') }}"/>
    </div>
    <div class="menores">
        <strong>Importante:</strong> Los usuarios menores de 18 años serán dados de baja.
    </div>
</form>
<script type="text/javascript">
    $( "#fos_user_registration_form_cumple" ).datepicker({
            showOn: "button",
            changeMonth: true,
            changeYear: true,
            yearRange: 'c-80:c',
            defaultDate: '-18y',
            dateFormat: 'dd/mm/yy',
            maxDate: '-17y',
            buttonImage: buttonCalendario,
            //buttonImage: "/images/calendar.gif",
            buttonImageOnly: true
    });

    $('#modal-form-registro').validate({
        invalidHandler: function(){
            
        },
        errorPlacement: function(error, element) {
            element.parent().find('div.error').append(error);
        },
        submitHandler: function(form) {
            form.submit();
        }
    });
    $("#fos_user_registration_form_email").rules("add", {
        required: true,
        email: true,
        remote: {
            url: "{{ path('validate_mail') }}",
            type: 'post'
        },
        messages: {
            required: "Por favor ingrese su e-mail",
            email: 'Por favor ingrese un e-mail v&aacute;lido',
            remote: 'El mail ingresado ya existe.'
        }
    });
    
    $("#fos_user_registration_form_nombre").rules("add", {
        required: true,
        messages: {
            required: 'Por favor ingrese su nombre'
        }
    });
    
    $("#fos_user_registration_form_cumple").rules("add", {
        required: true,
        messages: {
            required: 'Por favor ingrese su fecha de nacimiento'
        }
    });
    
    $("#fos_user_registration_form_plainPassword_first").rules("add", {
        required: true,
        messages: {
            required: 'Por favor ingrese su clave'
        }
    });
    
    $("#fos_user_registration_form_plainPassword_second").rules("add", {
        required: true,
        equalTo: "#fos_user_registration_form_plainPassword_first",
        messages: {
            required: 'Por favor repita su clave',
            equalTo: "Por favor ingrese las mismas claves"
        }
    });
    
    $("#fos_user_registration_form_pais-auto").rules("add", {
        required: true,
        messages: {
            required: 'Comience a escribir su ubicación y seleccione una de la lista que aparecerá'
        }
    });
    
    $("#fos_user_registration_form_descripcion").rules("add", {
        required:true,
        minlength:25,
        messages: {
            required: 'Por favor ingrese su descripción',
            minlength:'La descripción es demasiada corta'
        }
    });
    
    $("#chk-terminos").rules("add", {
        required:true,
        messages: {
            required: 'Debes aceptar los Términos y Condiciones para continuar'
        }
    });
    
</script>